<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SOP</title>
<link href="resources/styles/main.css" rel="stylesheet" type="text/css" />
<link type="text/css" href="resources/scripts/jquery-ui-1.8.14.custom/css/start/jquery-ui-1.8.14.custom.css" rel="stylesheet" />
<script type="text/javascript" src="resources/scripts/jquery-ui-1.8.14.custom/js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="resources/scripts/jquery-ui-1.8.14.custom/js/jquery-ui-1.8.14.custom.min.js"></script>
<script type="text/javascript" src="resources/scripts/jquery-ui-1.8.14.custom/js/jquery.blockUI.js"></script>
<script type="text/javascript" src="resources/scripts/jquery.blockUI.js"></script>
<script type="text/javascript">

//检查用户名
function checkUsername(username)
{
	var reg = /^[a-zA-Z0-9_]+$/;
	return reg.test(username);
}

var selectedUser = 0;
var selectedid = -1;
var selectedschool = -1;

$(document).ready(function(){
	$('.table_eachline').mouseover(function(){
			$(this).find('td').css('background', '#DEDEDE');
		});
	
	$('.table_eachline').mouseout(function(){
			$(this).find('td').css('background', '#FFFFFF');
		});
	
	$('#addSchool').dialog({ 
		autoOpen: false,
		buttons: {
				"提交": function() {
						if(!checkUsername($('#username').val()))
						{
							$('#errMsgAddSchool').html('用户名不合法');
							return;
						}
						if($('#schoolname').val()=='')
						{
							$('#errMsgAddSchool').html('学校名不能为空');
							return;
						}
						if(!(checkUsername($('#schoolpwd').val())))
						{
							$('#errMsgAddSchool').html('密码不能为空');
							return;
						}
						if($('#schoolpwd').val() != $('#schoolpwdConfirm').val())
						{
							$('#errMsgAddSchool').html('密码和确认密码不一致');
							return;
						}
						$('#errMsgAddSchool').html('<span style="color: green;"></span>');
						$.blockUI({message:'正在提交，请稍等'});
						$.post(
							'<!--{spUrl c=unit_super a=addSchool}-->',
							{
								'schoolname': $('#schoolname').val(),
								'zone': $('#zone').val(),
								'username': $('#username').val(),
								'schoolpwd': $('#schoolpwd').val()
							},
							function(data) {
								$.unblockUI();
								if(data == -1)
								{
									$('#errMsgAddSchool').html('提交出现错误，请稍候重试');
									return false;
								}
								else if(data == -2)
								{
									$('#errMsgAddSchool').html('用户名已经存在');
									return false;
								}
								else
									window.location.reload();
							}
						);
					},
				"关闭": function() {
						$(this).dialog('close');
					}
			}
		});
		
	$('#repwd').dialog({ 
		autoOpen: false,
		buttons: {
			"提交": function() {
					if(!checkUsername($('#oldpwd').val()))
					{
						$('#errMsgRepwd').html('密码不能为空');
						return;
					}
					if(!(checkUsername($('#repwdInput').val())))
					{
						$('#errMsgRepwd').html('密码不能为空');
						return;
					}
					if($('#repwdInput').val() != $('#repwdInputConfirm').val())
					{
						$('#errMsgRepwd').html('密码和确认密码不一致');
						return;
					}
					$('#errMsgRepwd').html('<span style="color: green;"></span>');
					$.blockUI({message:'正在提交，请稍等'});
					$.post(
						'<!--{spUrl c=unit_super a=repwd}-->',
						{
							'oldpwd': $('#oldpwd').val(),
							'pwd': $('#repwdInput').val(),
							'selectedUser' : selectedUser
						},
						function(data) {
							$.unblockUI();
							if(data == -1)
							{
								$('#errMsgRepwd').html('密码错误');
								return false;
							}
							else
								window.location.reload();
						}
					);
				},
			"关闭": function() {
					$(this).dialog('close');
			}
		}
	});
	
	$('.add').click(function(){
		$('#addSchool').dialog('open');
		return false;
	});
	
	$('.repwdLink').click(function(){
		selectedUser = $(this).attr('rel');
		$('#repwd').dialog('open');
		return false;
	});
	
		
	$('#repwdMy').dialog({ 
		autoOpen: false,
		buttons: {
				"提交": function() {
						if(!checkUsername($('#oldpwdMy').val()))
						{
							$('#errMsgRepwdMy').html('密码不能为空');
							return;
						}
						if(!(checkUsername($('#repwdInputMy').val())))
						{
							$('#errMsgRepwdMy').html('密码不能为空');
							return;
						}
						if($('#repwdInputMy').val() != $('#repwdInputConfirmMy').val())
						{
							$('#errMsgRepwdMy').html('密码和确认密码不一致');
							return;
						}
						$('#errMsgRepwdMy').html('<span style="color: green;"></span>');
						$.blockUI({message:'正在提交，请稍等'});
						$.post(
							'<!--{spUrl c=main a=changeMyPwd}-->',
							{
								'oldpwd': $('#oldpwdMy').val(),
								'pwd': $('#repwdInputMy').val(),
								'selectedUser' : "<!--{$user.id}-->"
							},
							function(data) {
								$.unblockUI();
								if(data == -1)
								{
									$('#errMsgRepwdMy').html('密码错误');
									return;
								}
								else
								{
									alert('密码修改成功');
									window.location.reload();
								}
							}
						);
					},
				"关闭": function() {
						$(this).dialog('close');
					}
			}
		});
	
	
		$('#delConfirm').dialog({ 
		autoOpen: false,
		buttons: {
				"是": function() {
						$.blockUI({message:'正在提交，请稍候...'});
						$.post(
							'<!--{spUrl c=unit_super a=del}-->',
							{
								'id' : selectedid,
								'schoolid': selectedschool
							},
							function(data) {
								$.unblockUI();
								if(data == -1)
								{
									alert('提交出现错误，请稍候重试');
									return false;
								}
								else
									window.location.reload();
							}
						);
					},
				"否": function() {
						$(this).dialog('close');
					}
			}
		});
		
		$('#editSchool').dialog({ 
		autoOpen: false,
		buttons: {
				"提交": function() {
						if(!checkUsername($('#usernameEdit').val()))
						{
							$('#errMsgEditSchool').html('用户名不合法');
							return;
						}
						if($('#schoolnameEdit').val()=='')
						{
							$('#errMsgEditSchool').html('学校名不能为空');
							return;
						}
						$('#errMsgEditSchool').html('<span style="color: green;"></span>');
						$.blockUI({message:'正在提交，请稍等'});
						$.post(
							'<!--{spUrl c=unit_super a=editSchool}-->',
							{
								'schoolname': $('#schoolnameEdit').val(),
								'zone': $('#zoneEdit').val(),
								'username': $('#usernameEdit').val(),
								'id': selectedid,
								'schoolid': selectedschool
							},
							function(data) {
								$.unblockUI();
								if(data == -1)
								{
									$('#errMsgEditSchool').html('提交出现错误，请稍候重试');
									return false;
								}
								else if(data == -2)
								{
									$('#errMsgEditSchool').html('用户名已经存在');
									return false;
								}
								else
									window.location.reload();
							}
						);
					},
				"关闭": function() {
						$(this).dialog('close');
					}
			}
		});
		
		
		$('.repwdLinkMy').click(function(){
			$('#repwdMy').dialog('open');
			return false;
		});
		
		$('.edit').click(function(){
			selectedid = $(this).attr('rel');
			selectedschool = $(this).attr('metadata');
			$('#usernameEdit').val($(this).attr('value'));	
			$('#zoneEdit').val($(this).attr('zone'));
			$('#schoolnameEdit').val($(this).attr('source'));	
			$('#editSchool').dialog('open');
			return false;	
		});
		
		$('.del').click(function(){
			selectedid = $(this).attr('rel');
			selectedschool = $(this).attr('metadata');
			$('#delConfirm').dialog('open');
			return false;	
		});
		
		
});
</script>
</head>

<body>
<div id="delConfirm" style="width: 320px; height: 240px; display:none;">
  <p>确认删除？</p>
</div>
<div id="editSchool" style="width: 320px; height: 240px; display:none;">
  <form method="POST">
    <table>
      <tr>
      	<td colspan="2"><span style="color: #900; " id="errMsgEditSchool"></span></td>
      </tr>
      <tr>
        <td>学校名：</td>
        <td><input id="schoolnameEdit" type="text" name="schoolname"/></td>
      </tr>
      <tr>
        <td>地区名：</td>
        <td><input id="zoneEdit" type="text" name="zone"/></td>
      </tr>
      <tr>
        <td>用户名：</td>
        <td><input id="usernameEdit" type="text" name="username"/></td>
      </tr>
    </table>
  </form>
</div>
<div id="addSchool" style="width: 320px; height: 240px; display:none;">
  <form method="POST">
    <table>
      <tr>
      	<td colspan="2"><span style="color: #900; " id="errMsgAddSchool"></span></td>
      </tr>
      <tr>
        <td>学校名：</td>
        <td><input id="schoolname" type="text" name="schoolname"/></td>
      </tr>
      <tr>
        <td>地区名：</td>
        <td><input id="zone" type="text" name="zone"/></td>
      </tr>
      <tr>
        <td>用户名：</td>
        <td><input id="username" type="text" name="username"/></td>
      </tr>
      <tr>
        <td>密码：</td>
        <td><input id="schoolpwd" type="password" name="schoolpwd" /></td>
      </tr>
      <tr>
        <td>重复密码：</td>
        <td><input id="schoolpwdConfirm" type="password" name="schoolpwdConfirm" /></td>
      </tr>
    </table>
  </form>
</div>
<div id="repwd" style="width: 320px; height: 240px; display:none;">
  <form method="POST">
    <table>
      <tr>
      	<td colspan="2"><span style="color: #900; " id="errMsgRepwd"></span></td>
      </tr>
      <tr>
        <td>新密码：</td>
        <td><input id="repwdInput" type="password" name="repwdInput" /></td>
      </tr>
      <tr>
        <td>重复新密码：</td>
        <td><input id="repwdInputConfirm" type="password" name="repwdInputConfirm" /></td>
      </tr>
    </table>
  </form>
</div>
<div id="repwdMy" style="width: 320px; height: 240px; display:none;">
  <form method="POST">
    <table>
      <tr>
      	<td colspan="2"><span style="color: #900; " id="errMsgRepwdMy"></span></td>
      </tr>
      <tr>
        <td>旧密码：</td>
        <td><input id="oldpwdMy" type="password" name="oldpwdMy"/></td>
      </tr>
      <tr>
        <td>新密码：</td>
        <td><input id="repwdInputMy" type="password" name="repwdInputMy" /></td>
      </tr>
      <tr>
        <td>重复新密码：</td>
        <td><input id="repwdInputConfirmMy" type="password" name="repwdInputConfirmMy" /></td>
      </tr>
    </table>
  </form>
</div>
<table width="100%" height="316" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<table border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="63" valign="top" background="resources/images/bgc10.gif" style="padding:30px 0px 0px 35px"><table width="93%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td bgcolor="#8ac281" class="b06">超级管理员管理页面</td>
                <td><img src="resources/images/bgc11.gif" width="26" height="52" /></td>
              </tr>
            </table></td>
          <td align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="23" align="right"><span class="b05"> 您好， </span><span class="b07">超级管理员</span><span class="b05"> 上次登录：</span><span class="b16"><!--{$user.last_login_date}--> </span><span class="b05">[<a href="<!--{spUrl c=main a=logout}-->">安全登出</a>]  [<a href="#" class="repwdLinkMy">密码修改</a>] </span></td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td background="resources/images/bgc02.gif"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:5px">
        <tr>
          <td height="40"><img src="resources/images/bgc05.gif" align="absmiddle" /><span class="b01">学校管理</span></td>
          <td align="right"><a href="<!--{spUrl c=export_tables a=total_info}-->">浏览总表</a></td>
        </tr>
        <tr>
          <td width="56%" height="1" background="resources/images/bgc04.gif"></td>
          <td width="44%" background="resources/images/bgc04.gif"></td>
        </tr>
      </table>
      <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" background="resources/images/bgc08.gif" style="margin:25px auto 15px auto">
        <tr>
          <td height="32" style="padding-left:15px"><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><table border="0" cellpadding="0" cellspacing="0" class="b02" >
                    <tr>
                      <td><a href="#">学校管理</a></td>
                    </tr>
                  </table></td>
                <td><table border="0" cellpadding="0" cellspacing="0" class="b03">
                    <tr>
                      <td><a href="<!--{spUrl c=unit_super a=config}-->">相关设置</a></td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
      </table>
      <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> </tr>
      </table>
      <table border="0" align="center" cellpadding="0" cellspacing="0" style="margin:15px auto 25px auto">
        <tr>
          <td><img src="resources/images/ke15.gif" width="864" height="5" /></td>
        </tr>
        <tr>
          <td><table width="864" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#dfdfdf">
              <tr>
                <td width="856" align="center" bgcolor="#FFFFFF"><table width="95%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#DDDDDD"  style=" margin:20px;">
                    <tr>
                      <td height="5" align="center" bgcolor="#f7f7f7" class="b05">计数</td>
                      <td height="20" align="center" bgcolor="#f7f7f7" class="b05">学校</td>
                      <td align="center" bgcolor="#f7f7f7" class="b05">地区</td>
                      <td width="150" height="25" align="center" bgcolor="#f7f7f7" class="b05">管理用户名</td>
                      <td width="150" align="center" bgcolor="#f7f7f7" class="b05">管理密码</td>
                      <td width="150" align="center" bgcolor="#f7f7f7" class="b05">选择操作</td>
                    </tr>
                    <!--{foreach from=$schools item=one name=schoolloop}-->
                    <tr class="table_eachline">
                      <td height="30" align="center" bgcolor="#FFFFFF" class="b12"><!--{$smarty.foreach.schoolloop.iteration}--></td>
                     
                      <td height="30" align="center" bgcolor="#FFFFFF" class="b12"><!--{$one.schoolname}--></td>
                       <td align="center" bgcolor="#FFFFFF" class="b12"><!--{$one.zone}--></td>
                      <td bgcolor="#FFFFFF" class="b15"><input readonly="readonly" name="rename_user" value="<!--{$one.username}-->" type="text" class="b11" id="textfield3" size="20" /></td>
                      <td align="center"  bgcolor="#FFFFFF" class="b15"><a href="#" class="repwdLink" rel="<!--{$one.id}-->">重设</a></td>
                      <td align="center" bgcolor="#FFFFFF" class="b07"><a href="#" class="edit" rel="<!--{$one.id}-->" value="<!--{$one.username}-->" zone="<!--{$one.zone}-->" metadata="<!--{$one.instanceids}-->" source="<!--{$one.schoolname}-->">修改</a> | <a href="#" class="del" rel="<!--{$one.id}-->" metadata="<!--{$one.instanceids}-->">删除</a> </td>
                    </tr>
                    <!--{/foreach}-->
                    <tr>
                      <td align="center" bgcolor="#CDCDCD" class="b12"><a href="#" class="add">+ 新增</a></td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td><img src="resources/images/ke14.gif" width="864" height="5" /></td>
        </tr>
      </table>
  </tr>
  <tr>
    <td><img src="resources/images/bgc03.gif" width="960" height="20" /></td>
  </tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="b04">
  <tr>
    <td height="80">&nbsp;</td>
  </tr>
</table>
</body>
</html>
